<template>
  <div>
    <!-- <MyHeader :title="$store.state.user.name"></MyHeader> -->
    <!-- <MyHeader :title="name"></MyHeader> -->
    <MyHeader title="购物车案例"></MyHeader>
    <div class="main">
      <MyGoods
        v-for="(obj,index) in list"
        :key="obj.id"
        :idx="index"
        :gObj="obj"
      ></MyGoods>
    </div>
    <MyFooter></MyFooter>
  </div>
</template>

<script>
import MyHeader from './components/MyHeader'
import MyGoods from './components/MyGoods'
import MyFooter from './components/MyFooter'
import { mapState, mapActions } from 'vuex'
export default {
  components: {
    MyHeader,
    MyGoods,
    MyFooter
  },
  computed: {
    ...mapState('cart', {list: 'goodsList'})
  },
  created(){
    // this.$store.dispatch('cart/asyncSetGoodsList')
    this.asyncSetGoodsList()
  },
  methods: {
    ...mapActions('cart', ['asyncSetGoodsList'])
  }
}
</script>

<style scoped>
  .main{
    padding-top: 45px;
    padding-bottom: 50px;
  }
</style>